package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Employee;
import cn.wolfcode.mapper.EmployeeMapper;
import cn.wolfcode.qo.EmployeeQuery;
import cn.wolfcode.service.IEmployeeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.mockito.internal.util.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class EmployeeServiceImpl extends ServiceImpl< EmployeeMapper, Employee > implements IEmployeeService {
    @Override
    public Page< Employee > query(EmployeeQuery qo) {

        Page< Employee > page = new Page<>(qo.getCurrentPage(),qo.getPageSize());
        //拼接条件使用的
        LambdaQueryWrapper< Employee > wrapper = Wrappers.< Employee >lambdaQuery();
        //拼接条件就相当于之前的where标签中的套条件当然也需要判空一下

            wrapper.like(StringUtils.hasLength(qo.getKeyWord()),Employee::getName,qo.getKeyWord());
        return super.page(page,wrapper);

    }
}
